<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title></title>
    <style type="text/css">
        .ui-layout-pane {
            border: 0px solid #8db2e3;
            padding: 0px;
            overflow: auto;
        }
    </style>
</head>
<script type="text/javascript">
    // $(document).ready(function () {
    //     $('body').layout();
    // });

    // function test() {

    function getXMLHttpRequest() {
        var client = getXMLHttpRequestFromIE();
        if (client == null) {
            client = new XMLHttpRequest();
        }
        return client;
    }

    function getXMLHttpRequestFromIE() {
        var namePrefixes = ["Msxml3", "Msxml2", "Msxml", "Microsoft"];
        for (var i = 0; i < namePrefixes.length; i++) {
            try {
                var name = namePrefixes[i] + ".XMLHTTP";
                return new ActiveXObject(name);
            } catch (e) {
            }
        }
        return null;
    }
    var client = null;
    //是否可以访问
    var isRun = false;
    //返回值
    var stateString = "";
    //请求url的网站
    function connUrl(url) {
        client = getXMLHttpRequest();
        var actionURL = convertURL(url);
        alert(actionURL);
        try {
            client.open("GET", actionURL, false);
            client.onreadystatechange = callBack;
            client.send(null);
        } catch (e) {
        }
        finally {
        }
    }
    function callBack() {
        if (client.readyState == 4) {
            stateString = client.responseText;
            if (stateString && client.status == 200)
                isRun = true;
        }
    }
    //是否可达
    function isReach(url) {
        connUrl(url);
        return isRun;
    }
    //给url地址增加时间戳，骗过浏览器，不读取缓存
    function convertURL(url) {
        //获取时间戳
        var timstamp = (new Date()).valueOf();
        //将时间戳信息拼接到url上
        if (url.indexOf("?") >= 0) {
            url = url + "&t=" + timstamp;
        } else {
            url = url + "?t=" + timstamp;
        }
        return url;
    }
    //因为是异步，先调用，此时isRun的值是false
    isReach("www.baidu.com");
    //3秒钟后判断isRun的值，如果为false认为网站不可达，类似超时时间
    setTimeout(function () {
        //alert(stateString);
        //alert(isRun);
        if (isRun == true) {
            document.getElementById("ceshi").innerText = "网站是通的！";
        } else {
            document.getElementById("ceshi").innerText = "网站不通！";
        }
    }, 3000);


    // 	var xmlhttp;
    // 	if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
    // 	  xmlhttp=new XMLHttpRequest(); //创建 XMLHttpRequest 对象
    // 	  } else {// code for IE6, IE5
    // 	  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); //则创建 ActiveXObject针对IE5，IE6
    // 	  }
    // 		xmlhttp.onreadystatechange=function() {
    // 		  if (xmlhttp.readyState==4 && xmlhttp.status==200) {
    // 			  // 			document.getElementById("myDiv").innerHTML=xmlhttp.responseText;
    // 			  alert("2222");
    // 		  } else {
    // 			  alert("1111");
    // 		  }
    // 	}
    // 	xmlhttp.open("GET","http://192.168.0.4:7080/report/ReportServer?reportlet=gtimp/declarationPackingList.cpt&id=402880854bfd220d014c07ac69c70006",true);
    // 	xmlhttp.send();
    // }

    // var xmlHttp= null;
    //        //判断浏览器
    //         function createXMLHttpRequest() {
    //             if (window.XMLHttpRequest) {
    //                 //Firefox,Netscape,Chrome,Safari等浏览器
    //                 xmlHttp = new XMLHttpRequest();
    //             } else if (window.ActiveXObject) { //IE浏览器
    //                 try {
    //                     xmlHttp = new ActiveXObject("Msxml2.XMLHTTP"); //创建xmlHttp对象
    //                 } catch (e) {
    //                     try {
    //                         xmlHttp = new ActiveXObject("Microsoft.XMLHTTP"); //创建xmlHttp对象
    //                     } catch (e) { }
    //                 }
    //             }
    //         }
    //      function   GetURL(url){
    //       createXMLHttpRequest();
    //       xmlHttp.open("GET",url,true);
    //           xmlHttp.send(null);
    //           xmlHttp.onreadystatechange = function(){
    //               alert(xmlHttp.readyState);
    //               alert(xmlHttp.status);
    //         	  if(xmlHttp.readyState==4){
    //                     if(xmlHttp.status==200){
    //                         alert("页面存在");
    //                     }else {
    //                         alert("页面不存在");
    //                     }
    //                   }
    //           }
    //   }


</script>
<body>
<!-- 	<iframe id='west' class="ui-layout-west west" src="tree.html" frameborder="0" -->
<!-- 		scrolling="auto"></iframe> -->
<!-- 	<iframe id='center' class="ui-layout-center center" src="grid.html" frameborder="0" -->
<!-- 		scrolling="auto"></iframe> -->
<!-- 			<input type="button" name="btn" value="测试" onclick="test();"/> -->
<!-- 		<input type="button" onclick="GetURL('http://192.168.0.4:7080/report/ReportServer?reportlet=gtimp/declarationPackingList.cpt&id=402880854bfd220d014c07ac69c70006')";    -->
<!--             value="该页面存在">     -->
<!--         <input type="button"     -->
<!--             onclick="GetURL('http://www.error.com/error.html')" value="此页面不存在"> -->

<div id="ceshi"></div>

</body>
</html>